/********************************************************************
	created:	30:9:2007   21:33
	author:		tiamo
	purpose:	power
*********************************************************************/

#include "stdafx.h"

// power
NTSTATUS AppleKeyboardPower(__in PDEVICE_OBJECT pDeviceObject,__in PIRP pIrp)
{
	NTSTATUS statusRet = STATUS_SUCCESS;
	CDeviceExtension* pDevExt = static_cast<CDeviceExtension*>(pDeviceObject->DeviceExtension);
	PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation(pIrp);

	AppleDebugPrint(DBGLEVEL_INFO,"Enter AppleKeyboardPower %p,%p,%x,%x,%x\n",pDeviceObject,pIrp,
					pIrpSp->MinorFunction,pIrpSp->Parameters.Power.Type,pIrpSp->MinorFunction,pIrpSp->Parameters.Power.State);

	statusRet = IoAcquireRemoveLock(&pDevExt->m_removeLock,pIrp);
	if(NT_SUCCESS(statusRet))
	{
		PoStartNextPowerIrp(pIrp);
		IoSkipCurrentIrpStackLocation(pIrp);
		statusRet = PoCallDriver(pDevExt->m_pLowerDevice,pIrp);
		IoReleaseRemoveLock(&pDevExt->m_removeLock,pIrp);
	}
	else
	{
		PoStartNextPowerIrp(pIrp);
		pIrp->IoStatus.Status = statusRet;
		IoCompleteRequest(pIrp,IO_NO_INCREMENT);
	}

	AppleDebugPrint(DBGLEVEL_INFO,"Leave AppleKeyboardPower 0x%08x\n",statusRet);

	return statusRet;
}